﻿Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Public Class AnimationVulkanAusbruch
    Inherits ObjektAnimation
    Const HalteFrame As Integer = 2
    Dim Zaehler As Integer = 0
    Public Sub New(ByVal X As Integer, ByVal Y As Integer, ByVal Musikspielen As Boolean)
        MyBase.New(True, ObjektSpielfeld.Bodenschlacht)
        P.X = X
        P.Y = Y
        Frames = 9
        BildID = LoadTextur("VulkanAusbruch", Frames - 1)
        If DataSettings.MusikSound Then
            '    MusikEngine.LoadWav(DataSettings.Resourcenpfad + "Sound\Sound Effects\Overworld\Explosion+Bombe.wav", False)
        End If
    End Sub

    Public Overrides Function Malen(ByVal intColor As System.Drawing.Color, Optional ByVal Zoomfaktor As Single = 1.0, Optional ByVal Feldbreite As Integer = -1) As Boolean
        If DataSettings.draw3D Then

        ElseIf DataSettings._2D_3D_Malen Then
            Dim T As Textur = Texturen(BildID)

            Dim MittelPunkt As New Point

            Dim XPlus As Single = -MittelPunkt.X / Hauptmenue.Feldbreite
            Dim YPlus As Single = -(T.EinzelbildGroesse.Height - MittelPunkt.Y) / Hauptmenue.Feldbreite

            Dim Rechts As Single = (T.EinzelbildGroesse.Width) / Hauptmenue.Feldbreite
            Dim Oben As Single = (T.EinzelbildGroesse.Height) / Hauptmenue.Feldbreite

            Dim FrameSize As Single = 1 / (Frames)

            Dim cube(3) As CustomVertex.PositionTextured
            cube(0) = New CustomVertex.PositionTextured(0, 0, 0, FrameSize * Frame, 1)
            cube(1) = New CustomVertex.PositionTextured(0, 0, Oben * Zoomfaktor, FrameSize * Frame, 0)
            cube(2) = New CustomVertex.PositionTextured(Rechts * Zoomfaktor, 0, 0, FrameSize * Frame + FrameSize, 1)
            cube(3) = New CustomVertex.PositionTextured(Rechts * Zoomfaktor, 0, Oben * Zoomfaktor, FrameSize * Frame + FrameSize, 0)
            Dim Vec As Vector3
            Dim Y As Single = (Hauptmenue.Feldbreite * P.Y - 61 - Hauptmenue.Feldbreite * 2) / Hauptmenue.Feldbreite - YPlus
            Dim X As Single = (Hauptmenue.Feldbreite * P.X) / Hauptmenue.Feldbreite + XPlus
            Vec = ObjektSpielfeld.CalcDraw2D3DVec(X, ObjektSpielfeld.SpielfeldLayer.Animationen, Y)
            Grafikengine.malen2Din3D(Vec, cube, T.TexturBild, intColor)
        Else
            Dim sngRotation As Double = 0
            Dim T As Textur = Texturen(BildID)
            With Grafikengine.recBild
                .X = T.EinzelbildGroesse.Width * Frame : .Width = T.EinzelbildGroesse.Width
                .Y = 0 : .Height = T.EinzelbildGroesse.Height
            End With
            Grafikengine.ptfPosition = New Drawing.Point(Hauptmenue.Feldbreite * P.X + Objektverwalter.Spielfeld.BildschirmKooX - 6, Hauptmenue.Feldbreite * P.Y + Objektverwalter.Spielfeld.BildschirmKooY - 61 - Hauptmenue.Feldbreite - 13)
            Grafikengine.szfScale = Nothing
            Grafikengine.ptfRotCenter = Nothing
            Grafikengine.Sprite.Draw2D(T.TexturBild, Grafikengine.recBild, Grafikengine.szfScale, Grafikengine.ptfRotCenter, sngRotation, Grafikengine.ptfPosition, intColor)
        End If
        If HalteFrame <= Zaehler Then
            Frame += 1
            Zaehler = 0
        Else
            Zaehler += 1
        End If

        If Frame >= Frames Then
            Return False
        Else
            Return True
        End If

    End Function
End Class
